<?php
// +----------------------------------------------------------------------
// | sfadmin - Suifeng Administration
// +----------------------------------------------------------------------
// | Copyright (c) 2017-2020 http://suifeng.tech All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: suifeng <1787585212@qq.com>
// +----------------------------------------------------------------------

namespace app\wechat\controller\admin;

use app\admin\common\AdminController;

class Log extends AdminController
{
    public function index()
    {
        $pagination = $this->_get_pagination_data();

        $pagination['rows_count'] = model('wechat/log')
            ->where($pagination['where_map'])->count();

        $pagination['total_pages'] = ceil($pagination['rows_count'] / $pagination['page_size']);
        $pagination['page_num'] = $pagination['page_num'] > $pagination['total_pages'] ? 1 : $pagination['page_num'];

        $log_list = model('wechat/log')
            ->where($pagination['where_map'])
            ->page($pagination['page_num'], $pagination['page_size'])
            ->order($pagination['sort_field'], $pagination['sort_order'])
            ->select();

        $this->assign('log_list', $log_list);
        $this->assign('pagination', $pagination);
        $this->display('admin/log/log_list');
    }
}
